define(['dojo/_base/declare',
    'dojo/_base/window',
    'dojo/_base/lang',
    'dojo/dom-construct',
    'dojo/dom-style',
    'dojo/on'
], function(declare, win, lang, domConstruct, domStyle, on) {
    
    return declare([], {
        map: null,
        element: null,
        attachedEvent: null,
        options:{
            top: null,
            right: 10,
            bottom: 10,
            left: null
        },
        constructor:function(map, options){
            var self = this;
            lang.mixin(this.options, options)
            this.map = map;
            this.element = domConstruct.create("div",
                { innerHTML: "<div>x: {x}</div><div>y: {y}</div>"});
            domStyle.set(this.element,"display","none");
            // domConstruct.place(this.element, win.body());
            domConstruct.place(this.element, dojo.byId(this.map.container));
            
            domStyle.set(this.element,{
                // "display":"block",
                "position": "absolute",
                "width": "130px",
                "user-select": "none"
            });
            this.options.top? domStyle.set(this.element, { "top": this.options.top +"px" }) : null;
            this.options.right? domStyle.set(this.element, { "right": this.options.right +"px" }) : null;
            this.options.bottom? domStyle.set(this.element, { "bottom": this.options.bottom +"px" }) : null;
            this.options.left? domStyle.set(this.element, { "left": this.options.left +"px" }) : null;
            this.attachedEvent = on(this.map, 'mouse-move', function(mouseEvent){
                var mapPoint = mouseEvent.mapPoint;
                self.element.innerHTML = "x: "+ parseFloat(''+  mapPoint.x ).toFixed(6)
                    +"<br/>" +  "y: "+ parseFloat(''+  mapPoint.y ).toFixed(6);
            });
        },
        show: function(){
            domStyle.set(this.element,{ "display":"block" });
        },
        hide: function(){
            domStyle.set(this.element,{ "display":"none" });
        },
        destroy: function(){
            domConstruct.destroy(this.element);
            this.attachedEvent.remove();
        }

    });

});